package com.burgeon.backend.SHOPBACKEND.rest.invite;
/**
 * 创建话术
 */
import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

public class AddExpressionsData extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public AddExpressionsData(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public String getData(String type,String value) throws Exception {
        String url = "http://" + ip + "/servlets/binserv/Rest";

        String str = RESULT(Data(type,value), url);

        System.err.println(str);
        String code = new JSONArray(str).getJSONObject(0).getString("code");
        String message= new JSONArray(str).getJSONObject(0).getString("message");

        if (!"0".equals(code)) {
            throw new Exception("创建失败"+message);
        }
        return code;
    }

    private MultiValueMap Data(String type, String value) {

        HashMap params = new HashMap();

        params.put("RVISITLAE_TYPE",type);
        params.put("RVISIT_CONTENT",value);


        params.put("table", "APP_VIP_RVISITLAE");//表名

        return DATA("ObjectCreate", params, account, password);
    }

    public static void main(String[] args) {
        AddExpressionsData g = new AddExpressionsData("39.104.73.78:5321", "nea@burgeon.com.cn", "burgeon5321");
        try {
g.getData("1","cscscscscscscscscscsc");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
